home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / others / ole_101.zip / SCHMOO.ZIP / FILEIO.C < prev    next >
C/C++ Source or Header  |  1992-04-13  |  2KB  |  99 lines

  1. /*
  2.  * FILEIO.C
  3.  *
  4.  * Functions for low-level reading and writing of .MOO files.
  5.  *
  6.  * Functions:
  7.  *  FMooFileRead, FMooFileWrite
  8.  *
  9.  * Copyright(c) Microsoft Corp. 1992 All Rights Reserved
  10.  *
  11.  */
  12.  
  13. #include <windows.h>
  14. #include "schmoo.h"
  15.  
  16.  
  17. /*
  18.  * FMooFileRead
  19.  *
  20.  * Purpose:
  21.  *  Reads a Moo file into the POLYLINE structure pointed to by lppl.
  22.  *  Clears pGlob->fDirty on success.
  23.  *
  24.  * Parameters:
  25.  *  pGlob           LPGLOBALS to the global variable block.
  26.  *  pszFile         LPSTR of the filename to read.
  27.  *  lppl            LPPOLYLINE to the structure to fill.
  28.  *
  29.  * Return Value:
  30.  *  BOOL            TRUE if the file was successfully read,
  31.  *                  FALSE otherwise.
  32.  */
  33.  
  34. BOOL FAR PASCAL FMooFileRead(LPGLOBALS pGlob, LPSTR pszFile, LPPOLYLINE lppl)
  35.     {
  36.     HANDLE      hFile;
  37.     OFSTRUCT    of;
  38.     WORD        cb;
  39.  
  40.     hFile=OpenFile(pszFile, &of, OF_READ);
  41.  
  42.     if (-1==hFile)
  43.         return FALSE;
  44.  
  45.     cb=_lread(hFile, (LPSTR)lppl, CBPOLYLINE);
  46.     _lclose(hFile);
  47.  
  48.     if (CBPOLYLINE==cb)
  49.         {
  50.         pGlob->fDirty=FALSE;
  51.         return TRUE;
  52.         }
  53.  
  54.     return FALSE;
  55.     }
  56.  
  57.  
  58.  
  59.  
  60. /*
  61.  * FMooFileWrite
  62.  *
  63.  * Purpose:
  64.  *  Writes a Moo file into the POLYLINE structure pointed to by lppl.
  65.  *  Clears pGlob->fDirty.
  66.  *
  67.  * Parameters:
  68.  *  pGlob           LPGLOBALS to the global variable block.
  69.  *  pszFile         LPSTR of the filename to read.
  70.  *  lppl            LPPOLYLINE to the structure to write from.
  71.  *
  72.  * Return Value:
  73.  *  BOOL            TRUE if the file was successfully written,
  74.  *                  FALSE otherwise.
  75.  */
  76.  
  77. BOOL FAR PASCAL FMooFileWrite(LPGLOBALS pGlob, LPSTR pszFile, LPPOLYLINE lppl)
  78.     {
  79.     HANDLE      hFile;
  80.     OFSTRUCT    of;
  81.     WORD        cb;
  82.  
  83.     hFile=OpenFile(pszFile, &of, OF_CREATE | OF_WRITE);
  84.  
  85.     if (-1==hFile)
  86.         return FALSE;
  87.  
  88.     cb=_lwrite(hFile, (LPSTR)lppl, CBPOLYLINE);
  89.     _lclose(hFile);
  90.  
  91.     if (CBPOLYLINE==cb)
  92.         {
  93.         pGlob->fDirty=FALSE;
  94.         return TRUE;
  95.         }
  96.  
  97.     return FALSE;
  98.     }
  99.